<?php

    if (isset($_GET['update']))
    {
        // On selectionne tous les pseudo
        $aPseudos1 = pg_query($oSql, 'SELECT DISTINCT pseudo FROM participation');
        $aPseudos2 = pg_query($oSql, 'SELECT DISTINCT pseudo FROM participation');

        // On selectionne les editions
        $aEditions = pg_query($oSql, 'SELECT edition FROM tournoi');
    }
    elseif (isset($_GET['del']))
    {
        // On supprime le tournoi
        pg_query($oSql, 'UPDATE participation SET round1 = NULL WHERE round1 = \'' . $_GET['del'] . '\'');
        pg_query($oSql, 'UPDATE participation SET round2 = NULL WHERE round2 = \'' . $_GET['del'] . '\'');
        pg_query($oSql, 'UPDATE participation SET round3 = NULL WHERE round3 = \'' . $_GET['del'] . '\'');
        pg_query($oSql, 'DELETE FROM match WHERE numero = \'' . $_GET['del'] . '\'');
    }

	//Requete de sélection globale
	$resData = pg_query($oSql, "	SELECT 	m1.nom AS nomj1, 
								m1.prenom AS prenomj1, 
								m1.pseudo AS pseudoj1, 
								m2.nom AS nomj2,
								m2.prenom AS prenomj2, 
								m2.pseudo AS pseudoj2,
								j1edition AS edition, 
								duree, 
								to_char(dateheure, 'YYYY/MM/DD') AS dateheure,
								pointegerj1,
								pointegerj2,
								numero 
			    		FROM match JOIN membre AS m1 ON match.j1pseudo = m1.pseudo JOIN membre AS m2 ON match.j2pseudo = m2.pseudo 
			    		ORDER BY numero DESC");

?>
